package exception;

public class FinallyDemo2 {
    public static void main(String[] args) {
        System.out.println(
                test("0") + "," + test(null) + "," + test("")
        );
    }

    public static int test(String str) {
        try {
            return str.charAt(0) - '0';
        } catch (NullPointerException e) {
            return 1;
        } catch (Exception e) {
            return 2;
        } finally {
            //finally中通常不应当有return，否则一定返回这个值。
            return 3;
        }
    }
}
